#pragma once
#include <memory>

#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
#include <proj_api.h>

#include "modules/common_msgs/sensor_msgs/gnss.pb.h"
#include "modules/common_msgs/sensor_msgs/gnss_best_pose.pb.h"
#include "modules/drivers/orin_gnss_v2/proto/config.pb.h"

#include "cyber/cyber.h"
#include "modules/common/adapters/adapter_gflags.h"
#include "modules/common/math/kalman_filter.h"

DECLARE_string(gnss_best_pose_opt_topic);

namespace apollo {
namespace drivers {
namespace gnss {

using apollo::common::math::KalmanFilter;
using apollo::cyber::Component;     
using apollo::cyber::ComponentBase;
using apollo::drivers::gnss::Gnss;
using apollo::drivers::gnss::GnssBestPose;
using apollo::drivers::gnss::config::Config;

class KFPoseComponent : public Component<Gnss> {
 public:
  bool Init() override;
  bool Proc(const std::shared_ptr<Gnss>& gnss) override;

 private:
  projPJ wgs84pj_source_;
  projPJ utm_target_;

  std::unique_ptr<apollo::common::math::KalmanFilter<double, 6, 6, 0>> gnss_kf_;
  std::shared_ptr<apollo::cyber::Writer<GnssBestPose>> gnssbestpose_writer_ =
      nullptr;
  std::shared_ptr<apollo::cyber::Reader<GnssBestPose>> bestpose_reader_ =
      nullptr;
};

CYBER_REGISTER_COMPONENT(KFPoseComponent)
}  // namespace gnss
}  // namespace drivers
}  // namespace apollo